-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link image assets by reference instead of by name #22
Conversation
- Reference assets by reference instead of name
- Include judge and host images by reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh i honestly can't say I'm convinced this is better. I get the safety you get from importing like this but I still think there's better ways. I think this increases friction if we ever want to manipulate the data files. For example, if we want to break down the events page into smaller, digestible chunks (since current events page is growing pretty fast) we have to manually play around with the files. By putting all our files into json files, we can manipulate them however we want (convert them to any other data format, insert it into a database, split up data files) but I don't see any significant updates on this front for the forseeable future so I'll approve but I do think there is a code smell here.
I can see how specifying objects instead of raw JSON may be slightly inconvenient, but I don't see how that would limit us from manipulating the data in the ways you specified: we can still split the data or convert it. Additionally, if we actually were storing image paths in a database, it wouldn't really make more sense to reference paths in the repository: we would want to store the actual image externally. Also, I just found the real reason things broke is since Webpack 5 changed how assets are bundled and I upgraded to react-scripts v5. |
Essentially we would ahve to move things around manually. If I wanted to reorganize the way we stored data (say we wanted to regroup certain properties), we have to manually manipulate the code. I'll give you a concrete example. Let's say we wanted to remove the "links" attribute from events that have no links (i.e. an empty array). I'd much rather write a script to read in the file, edit it, and then save it. Otherwise, we'd have to manually edit the file. This is a basic example since for this, you could probably just cntrl+f and replace but if something takes any more steps, it's easier to manipulate a json file bc you can read it in and edit it. If you store data in a database, using path references is how we would do it. We would store the images in a storage services like an S3 bin or GCP storage, which would return to us an image url, which we then save in the data base. What I originally meant though was that if we use a database, we could write a script to convert the json data into the database schema so we can automatically populate the data, rather than manual entry. If the only reason we have to use .js files is to ensure static type checking, then I'd say we're better off implementing TS or some sort of linter. Using js imports seems like a hack that introduces friction. If you're convinced this is better temp solution though, feel free to merge it, otherwise, we can split the webpack change into a separate PR and merge that immediately and leave this for discussion 🧜♀️ |
Sorry, I might have confused this asset issue with some other issue I had a long time ago or something else I was thinking of implementing. Using |
Link image assets by reference instead of using
require
which is unstable. This will provide compile-time guarantees that all necessary images are imported properly. This should address the issue where the build output from the deployment workflow in #18 was unable to provide dynamically linked images. Closes #21.